import vue from '@vitejs/plugin-vue'

import Unocss from 'unocss/vite'
import { VxeTableResolve, createStyleImportPlugin } from 'vite-plugin-style-import'
import createAutoImport from './auto-import'
import createSvgIcon from './svg-icon'
import createCompression from './compression'
import createSetupExtend from './setup-extend'
import createComponents from './components'

export default function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [vue()]
  vitePlugins.push(createAutoImport())
  vitePlugins.push(createSetupExtend())
  vitePlugins.push(createSvgIcon(isBuild))
  vitePlugins.push(createComponents())
  vitePlugins.push(
    createStyleImportPlugin({
      resolves: [
        VxeTableResolve(),
      ],
    }),
  )
  vitePlugins.push(Unocss())
  isBuild && vitePlugins.push(...createCompression(viteEnv))
  return vitePlugins
}
